package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("api/apiclient")
public @caption("API客户端") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("srv_api_client") class SrvApiClient implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("sac_id")    @primary  @notnull  @note("  ") Long sacId;// 主键 非空     
	private @caption("客户端ID") @column("sac_client")     @notnull  @note("  ") String sacClient;// 非空     
	private @caption("客户密钥") @column("sac_secret")     @notnull  @note("  ") String sacSecret;// 非空     
	private @caption("访问类型") @column("sac_type")     @notnull  @note(" 0:配置接口 1:全量模型  ") Short sacType;// 非空 0:配置接口 1:全量模型     
	private @caption("回调地址") @column("sac_url")      @note("  ") String sacUrl;//     
	private @caption("描述") @column("sac_desc") @like     @note("  ") String sacDesc;//     
	private @caption("修改时间") @column("sac_update_time")     @notnull  @note("  ") Date sacUpdateTime;// 非空     
	private @caption("添加时间") @column("sac_add_time")     @notnull  @note("  ") Date sacAddTime;// 非空     
	private @caption("状态") @column("sac_status")     @notnull  @note(" 1:正常 0:无效  ") Short sacStatus;// 非空 1:正常 0:无效     
	 
	//默认构造函数
	public SrvApiClient(){ 
	
	}
	
	//主键构造函数
	public SrvApiClient(Long id){
		this.sacId = id;
	}
	
	/**所有字段构造函数 
	 SrvApiClient(
	 	Utils.getString("sacClient")//客户端ID [非空]
	 	,Utils.getString("sacSecret")//客户密钥 [非空]
	 	,Utils.getShort("sacType")//访问类型 [非空]
	 	,Utils.getString("sacUrl")//回调地址
	 	,Utils.getString("sacDesc")//描述
	 	,Utils.getDate("sacUpdateTime")//修改时间 [非空]
	 	,Utils.getDate("sacAddTime")//添加时间 [非空]
	 	,Utils.getShort("sacStatus")//状态 [非空]
	 )
	**/
	public SrvApiClient(String sacClient,String sacSecret,Short sacType,String sacUrl,String sacDesc,Date sacUpdateTime,Date sacAddTime,Short sacStatus){
		this.sacClient=sacClient;
		this.sacSecret=sacSecret;
		this.sacType=sacType;
		this.sacUrl=sacUrl;
		this.sacDesc=sacDesc;
		this.sacUpdateTime=sacUpdateTime;
		this.sacAddTime=sacAddTime;
		this.sacStatus=sacStatus;
	}
	
	//设置非空字段
	public SrvApiClient setNotNull(String sacClient,String sacSecret,Short sacType,Date sacUpdateTime,Date sacAddTime,Short sacStatus){
		this.sacClient=sacClient;
		this.sacSecret=sacSecret;
		this.sacType=sacType;
		this.sacUpdateTime=sacUpdateTime;
		this.sacAddTime=sacAddTime;
		this.sacStatus=sacStatus;
		return this;
	}
	/** 编号 [非空]       **/
	public SrvApiClient sacId(Long sacId){
		this.sacId = sacId;
		this.setSeted(F.sacId);
		return this;
	}
	/** 客户端ID [非空]       **/
	public SrvApiClient sacClient(String sacClient){
		this.sacClient = sacClient;
		this.setSeted(F.sacClient);
		return this;
	}
	/** 客户密钥 [非空]       **/
	public SrvApiClient sacSecret(String sacSecret){
		this.sacSecret = sacSecret;
		this.setSeted(F.sacSecret);
		return this;
	}
	/** 访问类型 [非空]   0:配置接口 1:全量模型     **/
	public SrvApiClient sacType(Short sacType){
		this.sacType = sacType;
		this.setSeted(F.sacType);
		return this;
	}
	/** 回调地址        **/
	public SrvApiClient sacUrl(String sacUrl){
		this.sacUrl = sacUrl;
		this.setSeted(F.sacUrl);
		return this;
	}
	/** 描述        **/
	public SrvApiClient sacDesc(String sacDesc){
		this.sacDesc = sacDesc;
		this.setSeted(F.sacDesc);
		return this;
	}
	/** 修改时间 [非空]       **/
	public SrvApiClient sacUpdateTime(Date sacUpdateTime){
		this.sacUpdateTime = sacUpdateTime;
		this.setSeted(F.sacUpdateTime);
		return this;
	}
	/** 添加时间 [非空]       **/
	public SrvApiClient sacAddTime(Date sacAddTime){
		this.sacAddTime = sacAddTime;
		this.setSeted(F.sacAddTime);
		return this;
	}
	/** 状态 [非空]   1:正常 0:无效     **/
	public SrvApiClient sacStatus(Short sacStatus){
		this.sacStatus = sacStatus;
		this.setSeted(F.sacStatus);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public SrvApiClient clone(){
		SrvApiClient clone = new SrvApiClient();
		clone.sacClient=this.sacClient;
		clone.sacSecret=this.sacSecret;
		clone.sacType=this.sacType;
		clone.sacUrl=this.sacUrl;
		clone.sacDesc=this.sacDesc;
		clone.sacUpdateTime=this.sacUpdateTime;
		clone.sacAddTime=this.sacAddTime;
		clone.sacStatus=this.sacStatus;
		return clone;
	}
	/**
	* 清除缓存
	**/
	public void clear(){
		Cache.clearObject(SrvApiClient.M.class);
		Cache.clearValue(SrvApiClient.M.class);
		Cache.deleteObject(SrvApiClient.class, this.getId());
	}
	
	/**
	* 清除缓存
	**/
	public static void clear(Long id){
		Cache.clearObject(SrvApiClient.M.class);
		Cache.clearValue(SrvApiClient.M.class);
		Cache.deleteObject(SrvApiClient.class, id);
	}
	
	
	/**
	 * 根据ID取API客户端
	 * @param id
	 * @return
	 */
	public static @api SrvApiClient get(Long id){		
		return getSrvApiClientById(id);
	}
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.sacId = id;
	}
	
	/**
	 * 获取所有API客户端
	 * @return
	 */
	public static @api List<SrvApiClient> list(Map params,Integer size){
		return getSrvApiClientList(params,size);
	}
	/**
	 * 获取API客户端分页
	 * @return
	 */
	public static @api Page<SrvApiClient> page(Integer page,Integer size,Map params){
		return getSrvApiClientPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取API客户端
	 * @param params
	 * @return
	 */
	public static @api SrvApiClient Get(Map params){
		return getSrvApiClient(params);
	}
	/**
	 * 获取API客户端数
	 * @return
	 */
	public static @api Long count(Map params){
		return getSrvApiClientCount(params);
	}
	/**
	 * 获取API客户端数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getSrvApiClientEval(eval,params);
	}
	/**
	 * 获取API客户端图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getSrvApiClientStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取API客户端图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getSrvApiClientStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取API客户端
	 * @param id
	 * @return
	 */
	public static @api SrvApiClient getSrvApiClientById(Long id){		
		return getSrvApiClientDao().getSrvApiClientById(id);
	}
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.sacId;
	}
	
	
	/**
	 * 根据ID取API客户端的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		value = Cache.getValue(SrvApiClient.class, id);
		if(value==null){
			SrvApiClient srvApiClient = get(id);
			if(srvApiClient!=null){
				String strValue = srvApiClient.getSacClient$();
				if(!"SacClient".equals("SacClient"))
					strValue+="("+srvApiClient.getSacClient$()+")";
				Cache.setValue(SrvApiClient.class, id ,strValue);
				value = strValue;
			}else{
				Cache.setValue(SrvApiClient.class, id ,"{"+id+"}",30);
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getSacClient$();
		if(!"SacClient".equals("SacClient"))
			keyValue+="("+this.getSacClient$()+")";
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询API客户端对象
	 * @return
	 */
	public static @api SrvApiClient find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("sacId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex+=" or sac_client = '"+key.replaceAll("'", "''")+"'";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return SrvApiClient.getSrvApiClient(params);
	}
	
	
	/**
	 * 根据关键字查询API客户端
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","sac_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("sacId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex+=" or sac_client like '%"+strTerm.replaceAll("'", "''")+"%'";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<SrvApiClient> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(SrvApiClient srvApiClient:list){
			Map map = new HashMap();
			map.put("key",srvApiClient.getSacId().toString());
			map.put("value", Utils.js(srvApiClient.getKeyValue()));
			if(bObject==true)
				map.put("object",srvApiClient);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有API客户端
	 * @return
	 */
	public static @api List<SrvApiClient> getSrvApiClientList(Map params,Integer size){
		return getSrvApiClientDao().getSrvApiClientList(params,0,size);
	}
	
	/**
	 * 获取API客户端分页
	 * @return
	 */
	public static @api Page<SrvApiClient> getSrvApiClientPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getSrvApiClientDao().getSrvApiClientPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取API客户端
	 * @param params
	 * @return
	 */
	public static @api SrvApiClient getSrvApiClient(Map params){
		return getSrvApiClientDao().getSrvApiClient(params);
	}
	
	/**
	 * 保存一个API客户端
	 * @param srvApiClient
	 * @return
	 */
	public static @api SrvApiClient saveSrvApiClient(SrvApiClient srvApiClient){
		return getSrvApiClientDao().saveSrvApiClient(srvApiClient);
	}
	
	/**
	 * 根据条件更新API客户端
	 * @param values
	 * @param params
	 */
	public static @api int updateSrvApiClientByConfirm(Map values, Map params){
		return getSrvApiClientDao().updateSrvApiClientByConfirm(values,params);
	}
	
	/**
	 * 修改一个API客户端
	 * @param srvApiClient
	 * @return
	 */
	public static @api int updateSrvApiClient(SrvApiClient srvApiClient){
		return getSrvApiClientDao().updateSrvApiClient(srvApiClient);
	}
	
	/**
	 * 更新API客户端非空字段
	 * @param srvApiClient
	 */
	public static @api int updateSrvApiClient$NotNull(SrvApiClient srvApiClient){
		return getSrvApiClientDao().updateSrvApiClient$NotNull(srvApiClient);
	}
	
	/**
	 * 获取API客户端数
	 * @return
	 */
	public static @api Long getSrvApiClientCount(Map params){
		return getSrvApiClientDao().getSrvApiClientCount(params);
	}
		
		
	/**
	 * 获取API客户端自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getSrvApiClientEval(String eval,Map params){
		return getSrvApiClientDao().getSrvApiClientEval(eval,params);
	}
	/**
	 * 获取API客户端图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getSrvApiClientStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getSrvApiClientDao().getSrvApiClientStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = SrvApiClient.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(SrvApiClient.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateSrvApiClient(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getSrvApiClientDao().updateSrvApiClientByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteSrvApiClient(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getSrvApiClientDao().deleteSrvApiClientByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getSrvApiClientDao().removeSrvApiClientById(id);
	}
	
	
	/**
	 * 保存API客户端对象
	 * @param params
	 * @return
	 */
	public SrvApiClient save(){
		if(this.getSacId()!=null)
			getSrvApiClientDao().updateSrvApiClient(this);
		else
			return getSrvApiClientDao().saveSrvApiClient(this);
		return this;
	}
	
	
	/**
	 * 更新API客户端对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getSrvApiClientDao().updateSrvApiClient$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getSrvApiClientDao().removeSrvApiClientById(this.getSacId());
		else
			getSrvApiClientDao().deleteSrvApiClientById(this.getSacId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getSrvApiClientDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getSacId(){
		if(this.sacId!=null){
			return this.sacId;
		}
		return this.sacId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getSacId$(){
		String strValue="";
		 strValue=Utils.string(this.getSacId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setSacId$(String strValue){
		if(Utils.empty(strValue)){
			this.sacId=null;
			return;
		}
	 	this.sacId=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setSacId(Long sacId){
		this.sacId = sacId;
		this.setSeted(F.sacId);
	}
	
	
	
	
	/*******************************客户端ID**********************************/	
	/**
	* 客户端ID [非空]      
	**/
	public String getSacClient(){
		if(this.sacClient!=null){
			return this.sacClient;
		}
		return this.sacClient;
	}
	/**
	* 获取客户端ID格式化(toString)
	**/
	public String getSacClient$(){
		String strValue="";
		 strValue=Utils.string(this.getSacClient());
	 	 return strValue;
	}
	/**
	* 根据客户端ID反格式化
	**/
	public void setSacClient$(String strValue){
		if(Utils.empty(strValue)){
			this.sacClient=null;
			return;
		}
	 	this.sacClient=strValue;
	}
	
	/**
	* 客户端ID [非空]      
	**/
	public void setSacClient(String sacClient){
		this.sacClient = sacClient;
		this.setSeted(F.sacClient);
	}
	
	
	
	
	/*******************************客户密钥**********************************/	
	/**
	* 客户密钥 [非空]      
	**/
	public String getSacSecret(){
		if(this.sacSecret!=null){
			return this.sacSecret;
		}
		return this.sacSecret;
	}
	/**
	* 获取客户密钥格式化(toString)
	**/
	public String getSacSecret$(){
		String strValue="";
		 strValue=Utils.string(this.getSacSecret());
	 	 return strValue;
	}
	/**
	* 根据客户密钥反格式化
	**/
	public void setSacSecret$(String strValue){
		if(Utils.empty(strValue)){
			this.sacSecret=null;
			return;
		}
	 	this.sacSecret=strValue;
	}
	
	/**
	* 客户密钥 [非空]      
	**/
	public void setSacSecret(String sacSecret){
		this.sacSecret = sacSecret;
		this.setSeted(F.sacSecret);
	}
	
	
	
	
	/*******************************访问类型**********************************/	
	/**
	* 访问类型 [非空]   0:配置接口 1:全量模型    
	**/
	public Short getSacType(){
		if(this.sacType!=null){
			return this.sacType;
		}
		return this.sacType;
	}
	/**
	* 获取访问类型格式化(toString)
	**/
	public String getSacType$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSacType()),"0"))
			strValue=Utils.string("配置接口");		 
		 if(Utils.equals(Utils.string(this.getSacType()),"1"))
			strValue=Utils.string("全量模型");		 
	 	 return strValue;
	}
	/**
	* 根据访问类型反格式化
	**/
	public void setSacType$(String strValue){
		if(Utils.empty(strValue)){
			this.sacType=null;
			return;
		}
		 if(Utils.equals(strValue,"配置接口"))
		 	this.sacType=Utils.parseShort("0");
		 if(Utils.equals(strValue,"全量模型"))
		 	this.sacType=Utils.parseShort("1");
	}
	
	/**
	* 访问类型 [非空]   0:配置接口 1:全量模型    
	**/
	public void setSacType(Short sacType){
		this.sacType = sacType;
		this.setSeted(F.sacType);
	}
	
	
	
	
	/*******************************回调地址**********************************/	
	/**
	* 回调地址       
	**/
	public String getSacUrl(){
		if(this.sacUrl!=null){
			return this.sacUrl;
		}
		return this.sacUrl;
	}
	/**
	* 获取回调地址格式化(toString)
	**/
	public String getSacUrl$(){
		String strValue="";
		 strValue=Utils.string(this.getSacUrl());
	 	 return strValue;
	}
	/**
	* 根据回调地址反格式化
	**/
	public void setSacUrl$(String strValue){
		if(Utils.empty(strValue)){
			this.sacUrl=null;
			return;
		}
	 	this.sacUrl=strValue;
	}
	
	/**
	* 回调地址       
	**/
	public void setSacUrl(String sacUrl){
		this.sacUrl = sacUrl;
		this.setSeted(F.sacUrl);
	}
	
	
	
	
	/*******************************描述**********************************/	
	/**
	* 描述       
	**/
	public String getSacDesc(){
		if(this.sacDesc!=null){
			return this.sacDesc;
		}
		return this.sacDesc;
	}
	/**
	* 获取描述格式化(toString)
	**/
	public String getSacDesc$(){
		String strValue="";
		 strValue=Utils.string(this.getSacDesc());
	 	 return strValue;
	}
	/**
	* 根据描述反格式化
	**/
	public void setSacDesc$(String strValue){
		if(Utils.empty(strValue)){
			this.sacDesc=null;
			return;
		}
		this.sacDesc=strValue;
	}
	
	/**
	* 描述       
	**/
	public void setSacDesc(String sacDesc){
		this.sacDesc = sacDesc;
		this.setSeted(F.sacDesc);
	}
	
	
	
	
	/*******************************修改时间**********************************/	
	/**
	* 修改时间 [非空]      
	**/
	public Date getSacUpdateTime(){
		if(this.sacUpdateTime!=null){
			return this.sacUpdateTime;
		}
		return this.sacUpdateTime;
	}
	/**
	* 获取修改时间格式化(toString)
	**/
	public String getSacUpdateTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSacUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据修改时间反格式化
	**/
	public void setSacUpdateTime$(String strValue){
		if(Utils.empty(strValue)){
			this.sacUpdateTime=null;
			return;
		}
	 	this.sacUpdateTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 修改时间 [非空]      
	**/
	public void setSacUpdateTime(Date sacUpdateTime){
		this.sacUpdateTime = sacUpdateTime;
		this.setSeted(F.sacUpdateTime);
	}
	
	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间 [非空]      
	**/
	public Date getSacAddTime(){
		if(this.sacAddTime!=null){
			return this.sacAddTime;
		}
		return this.sacAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getSacAddTime$(){
		String strValue="";
		 strValue=Utils.string(Utils.date(this.getSacAddTime(),"yyyy-MM-dd HH:mm:ss"));
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setSacAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.sacAddTime=null;
			return;
		}
	 	this.sacAddTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	}
	
	/**
	* 添加时间 [非空]      
	**/
	public void setSacAddTime(Date sacAddTime){
		this.sacAddTime = sacAddTime;
		this.setSeted(F.sacAddTime);
	}
	
	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public Short getSacStatus(){
		if(this.sacStatus!=null){
			return this.sacStatus;
		}
		return this.sacStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getSacStatus$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSacStatus()),"1"))
			strValue=Utils.string("正常");		 
		 if(Utils.equals(Utils.string(this.getSacStatus()),"0"))
			strValue=Utils.string("无效");		 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setSacStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.sacStatus=null;
			return;
		}
		 if(Utils.equals(strValue,"正常"))
		 	this.sacStatus=Utils.parseShort("1");
		 if(Utils.equals(strValue,"无效"))
		 	this.sacStatus=Utils.parseShort("0");
	}
	
	/**
	* 状态 [非空]   1:正常 0:无效    
	**/
	public void setSacStatus(Short sacStatus){
		this.sacStatus = sacStatus;
		this.setSeted(F.sacStatus);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(SrvApiClient.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(SrvApiClient.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(SrvApiClient.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(SrvApiClient.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(SrvApiClient.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${SrvApiClient.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvApiClient.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvApiClient.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(SrvApiClient.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${SrvApiClient.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${SrvApiClient.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return SrvApiClient.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(SrvApiClient.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M sacId(Object sacId){if(proxy)return proxy().sacId(sacId);  this.put("sacId", sacId);return this;};
	 	/** and sac_id is null */
 		public M sacIdNull(){if(proxy)return proxy().sacIdNull();if(this.get("sacIdNot")==null)this.put("sacIdNot", "");this.put("sacId", null);return this;};
 		/** not .... */
 		public M sacIdNot(){if(proxy)return proxy().sacIdNot();this.put("sacIdNot", "not");return this;};
 		public M sacIdNotNull(){if(proxy)return proxy().sacIdNotNull();this.put("sacIdNot", "not");this.put("sacId", null);return this;};
 		public M sacIdNot(Object sacId){if(proxy)return proxy().sacIdNot(sacId);this.put("sacIdNot", "not");this.put("sacId", sacId);return this;};
		/** and sac_id <= ? */
		public M sacIdMin(Object min){if(proxy)return proxy().sacIdMin(min);this.put("sacIdMin", min);return this;};
		/** and sac_id >= ? */
		public M sacIdMax(Object max){if(proxy)return proxy().sacIdMax(max);this.put("sacIdMax", max);return this;};
		public M sacIdIn(String ids){
			if(proxy)return proxy().sacIdIn(ids);  this.put("sacIdIn", ids);return this;
		};	
		/** 客户端ID [非空]       **/
		public M sacClient(Object sacClient){if(proxy)return proxy().sacClient(sacClient);  this.put("sacClient", sacClient);return this;};
	 	/** and sac_client is null */
 		public M sacClientNull(){if(proxy)return proxy().sacClientNull();if(this.get("sacClientNot")==null)this.put("sacClientNot", "");this.put("sacClient", null);return this;};
 		/** not .... */
 		public M sacClientNot(){if(proxy)return proxy().sacClientNot();this.put("sacClientNot", "not");return this;};
 		public M sacClientNotNull(){if(proxy)return proxy().sacClientNotNull();this.put("sacClientNot", "not");this.put("sacClient", null);return this;};
 		public M sacClientNot(Object sacClient){if(proxy)return proxy().sacClientNot(sacClient);this.put("sacClientNot", "not");this.put("sacClient", sacClient);return this;};
		/** 客户密钥 [非空]       **/
		public M sacSecret(Object sacSecret){if(proxy)return proxy().sacSecret(sacSecret);  this.put("sacSecret", sacSecret);return this;};
	 	/** and sac_secret is null */
 		public M sacSecretNull(){if(proxy)return proxy().sacSecretNull();if(this.get("sacSecretNot")==null)this.put("sacSecretNot", "");this.put("sacSecret", null);return this;};
 		/** not .... */
 		public M sacSecretNot(){if(proxy)return proxy().sacSecretNot();this.put("sacSecretNot", "not");return this;};
 		public M sacSecretNotNull(){if(proxy)return proxy().sacSecretNotNull();this.put("sacSecretNot", "not");this.put("sacSecret", null);return this;};
 		public M sacSecretNot(Object sacSecret){if(proxy)return proxy().sacSecretNot(sacSecret);this.put("sacSecretNot", "not");this.put("sacSecret", sacSecret);return this;};
		/** 访问类型 [非空]   0:配置接口 1:全量模型     **/
		public M sacType(Object sacType){if(proxy)return proxy().sacType(sacType);  this.put("sacType", sacType);return this;};
	 	/** and sac_type is null */
 		public M sacTypeNull(){if(proxy)return proxy().sacTypeNull();if(this.get("sacTypeNot")==null)this.put("sacTypeNot", "");this.put("sacType", null);return this;};
 		/** not .... */
 		public M sacTypeNot(){if(proxy)return proxy().sacTypeNot();this.put("sacTypeNot", "not");return this;};
 		public M sacTypeNotNull(){if(proxy)return proxy().sacTypeNotNull();this.put("sacTypeNot", "not");this.put("sacType", null);return this;};
 		public M sacTypeNot(Object sacType){if(proxy)return proxy().sacTypeNot(sacType);this.put("sacTypeNot", "not");this.put("sacType", sacType);return this;};
		public M sacTypeIn(String ids){
			if(proxy)return proxy().sacTypeIn(ids);  this.put("sacTypeIn", ids);return this;
		};	
		/** 回调地址        **/
		public M sacUrl(Object sacUrl){if(proxy)return proxy().sacUrl(sacUrl);  this.put("sacUrl", sacUrl);return this;};
	 	/** and sac_url is null */
 		public M sacUrlNull(){if(proxy)return proxy().sacUrlNull();if(this.get("sacUrlNot")==null)this.put("sacUrlNot", "");this.put("sacUrl", null);return this;};
 		/** not .... */
 		public M sacUrlNot(){if(proxy)return proxy().sacUrlNot();this.put("sacUrlNot", "not");return this;};
 		public M sacUrlNotNull(){if(proxy)return proxy().sacUrlNotNull();this.put("sacUrlNot", "not");this.put("sacUrl", null);return this;};
 		public M sacUrlNot(Object sacUrl){if(proxy)return proxy().sacUrlNot(sacUrl);this.put("sacUrlNot", "not");this.put("sacUrl", sacUrl);return this;};
		/** 描述        **/
		public M sacDesc(Object sacDesc){if(proxy)return proxy().sacDesc(sacDesc);  this.put("sacDesc", sacDesc);return this;};
	 	/** and sac_desc is null */
 		public M sacDescNull(){if(proxy)return proxy().sacDescNull();if(this.get("sacDescNot")==null)this.put("sacDescNot", "");this.put("sacDesc", null);return this;};
 		/** not .... */
 		public M sacDescNot(){if(proxy)return proxy().sacDescNot();this.put("sacDescNot", "not");return this;};
 		public M sacDescNotNull(){if(proxy)return proxy().sacDescNotNull();this.put("sacDescNot", "not");this.put("sacDesc", null);return this;};
 		public M sacDescNot(Object sacDesc){if(proxy)return proxy().sacDescNot(sacDesc);this.put("sacDescNot", "not");this.put("sacDesc", sacDesc);return this;};
		/** 修改时间 [非空]       **/
		public M sacUpdateTime(Object sacUpdateTime){if(proxy)return proxy().sacUpdateTime(sacUpdateTime);  this.put("sacUpdateTime", sacUpdateTime);return this;};
	 	/** and sac_update_time is null */
 		public M sacUpdateTimeNull(){if(proxy)return proxy().sacUpdateTimeNull();if(this.get("sacUpdateTimeNot")==null)this.put("sacUpdateTimeNot", "");this.put("sacUpdateTime", null);return this;};
 		/** not .... */
 		public M sacUpdateTimeNot(){if(proxy)return proxy().sacUpdateTimeNot();this.put("sacUpdateTimeNot", "not");return this;};
 		public M sacUpdateTimeNotNull(){if(proxy)return proxy().sacUpdateTimeNotNull();this.put("sacUpdateTimeNot", "not");this.put("sacUpdateTime", null);return this;};
 		public M sacUpdateTimeNot(Object sacUpdateTime){if(proxy)return proxy().sacUpdateTimeNot(sacUpdateTime);this.put("sacUpdateTimeNot", "not");this.put("sacUpdateTime", sacUpdateTime);return this;};
 		/** and sac_update_time >= ? */
 		public M sacUpdateTimeStart(Object start){if(proxy)return proxy().sacUpdateTimeStart(start);this.put("sacUpdateTimeStart", start);return this;};			
 		/** and sac_update_time <= ? */
 		public M sacUpdateTimeEnd(Object end){if(proxy)return proxy().sacUpdateTimeEnd(end);this.put("sacUpdateTimeEnd", end);return this;};
		/** 添加时间 [非空]       **/
		public M sacAddTime(Object sacAddTime){if(proxy)return proxy().sacAddTime(sacAddTime);  this.put("sacAddTime", sacAddTime);return this;};
	 	/** and sac_add_time is null */
 		public M sacAddTimeNull(){if(proxy)return proxy().sacAddTimeNull();if(this.get("sacAddTimeNot")==null)this.put("sacAddTimeNot", "");this.put("sacAddTime", null);return this;};
 		/** not .... */
 		public M sacAddTimeNot(){if(proxy)return proxy().sacAddTimeNot();this.put("sacAddTimeNot", "not");return this;};
 		public M sacAddTimeNotNull(){if(proxy)return proxy().sacAddTimeNotNull();this.put("sacAddTimeNot", "not");this.put("sacAddTime", null);return this;};
 		public M sacAddTimeNot(Object sacAddTime){if(proxy)return proxy().sacAddTimeNot(sacAddTime);this.put("sacAddTimeNot", "not");this.put("sacAddTime", sacAddTime);return this;};
 		/** and sac_add_time >= ? */
 		public M sacAddTimeStart(Object start){if(proxy)return proxy().sacAddTimeStart(start);this.put("sacAddTimeStart", start);return this;};			
 		/** and sac_add_time <= ? */
 		public M sacAddTimeEnd(Object end){if(proxy)return proxy().sacAddTimeEnd(end);this.put("sacAddTimeEnd", end);return this;};
		/** 状态 [非空]   1:正常 0:无效     **/
		public M sacStatus(Object sacStatus){if(proxy)return proxy().sacStatus(sacStatus);  this.put("sacStatus", sacStatus);return this;};
	 	/** and sac_status is null */
 		public M sacStatusNull(){if(proxy)return proxy().sacStatusNull();if(this.get("sacStatusNot")==null)this.put("sacStatusNot", "");this.put("sacStatus", null);return this;};
 		/** not .... */
 		public M sacStatusNot(){if(proxy)return proxy().sacStatusNot();this.put("sacStatusNot", "not");return this;};
 		public M sacStatusNotNull(){if(proxy)return proxy().sacStatusNotNull();this.put("sacStatusNot", "not");this.put("sacStatus", null);return this;};
 		public M sacStatusNot(Object sacStatus){if(proxy)return proxy().sacStatusNot(sacStatus);this.put("sacStatusNot", "not");this.put("sacStatus", sacStatus);return this;};
		public M sacStatusIn(String ids){
			if(proxy)return proxy().sacStatusIn(ids);  this.put("sacStatusIn", ids);return this;
		};	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有API客户端 **/
		public @api List<SrvApiClient> list(Integer size){			
			return getSrvApiClientList(this,size);
		}
		/** 获取API客户端分页 **/
		public @api Page<SrvApiClient> page(Integer page,Integer size){			
			return getSrvApiClientPage(page, size , this);
		}
		/** 根据查询条件取API客户端 **/
		public @api SrvApiClient get(){			
			return getSrvApiClient(this);
		}
		/** 获取API客户端数 **/
		public @api Long count(){			
			return getSrvApiClientCount(this);
		}
		/** 获取API客户端表达式 **/
		public @api <T> T eval(String strEval){			
			return getSrvApiClientEval(strEval,this);
		}
		/** 获取API客户端统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getSrvApiClientStats(this,sumKey,groupKey,dateType);
		}
		/** 获取API客户端统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getSrvApiClientStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateSrvApiClient(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteSrvApiClient(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String sacId="sacId";
		/** 客户端ID [非空]       **/
		public final static @type(String.class)  String sacClient="sacClient";
		/** 客户密钥 [非空]       **/
		public final static @type(String.class)  String sacSecret="sacSecret";
		/** 访问类型 [非空]   0:配置接口 1:全量模型     **/
		public final static @type(Short.class)  String sacType="sacType";
		/** 回调地址        **/
		public final static @type(String.class)  String sacUrl="sacUrl";
		/** 描述        **/
		public final static @type(String.class) @like String sacDesc="sacDesc";
		/** 修改时间 [非空]       **/
		public final static @type(Date.class)  String sacUpdateTime="sacUpdateTime";
	 	/** and sac_update_time >= ? */
 		public final static @type(Date.class) String sacUpdateTimeStart="sacUpdateTimeStart";
 		/** and sac_update_time <= ? */
 		public final static @type(Date.class) String sacUpdateTimeEnd="sacUpdateTimeEnd";
		/** 添加时间 [非空]       **/
		public final static @type(Date.class)  String sacAddTime="sacAddTime";
	 	/** and sac_add_time >= ? */
 		public final static @type(Date.class) String sacAddTimeStart="sacAddTimeStart";
 		/** and sac_add_time <= ? */
 		public final static @type(Date.class) String sacAddTimeEnd="sacAddTimeEnd";
		/** 状态 [非空]   1:正常 0:无效     **/
		public final static @type(Short.class)  String sacStatus="sacStatus";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		sacId("sac_id"),
		sacClient("sac_client"),
		sacSecret("sac_secret"),
		sacType("sac_type"),
		sacUrl("sac_url"),
		sacDesc("sac_desc"),
		sacUpdateTime("sac_update_time"),
		sacAddTime("sac_add_time"),
		sacStatus("sac_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取API客户端数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = SrvApiClient.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = SrvApiClient.getSrvApiClient(params);
			else
				value = SrvApiClient.getSrvApiClientList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  SrvApiClient.where().sacId(param).get();
		else if(!Utils.empty(param.toString()))
			value = SrvApiClient.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getSacId());
		Utils.fms(map,simple?"id":"sacId",this.getSacId(),this.getSacId$());
		Utils.fms(map,simple?"client":"sacClient",this.getSacClient(),this.getSacClient$());
		Utils.fms(map,simple?"secret":"sacSecret",this.getSacSecret(),this.getSacSecret$());
		Utils.fms(map,simple?"type":"sacType",this.getSacType(),this.getSacType$());
		Utils.fms(map,simple?"url":"sacUrl",this.getSacUrl(),this.getSacUrl$());
		Utils.fms(map,simple?"desc":"sacDesc",this.getSacDesc(),this.getSacDesc$());
		Utils.fms(map,simple?"updateTime":"sacUpdateTime",this.getSacUpdateTime(),this.getSacUpdateTime$());
		Utils.fms(map,simple?"addTime":"sacAddTime",this.getSacAddTime(),this.getSacAddTime$());
		Utils.fms(map,simple?"status":"sacStatus",this.getSacStatus(),this.getSacStatus$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("sacId",this.getSacId());
		map.put("sacClient",this.getSacClient());
		map.put("sacSecret",this.getSacSecret());
		map.put("sacType",this.getSacType());
		map.put("sacUrl",this.getSacUrl());
		map.put("sacDesc",this.getSacDesc());
		map.put("sacUpdateTime",this.getSacUpdateTime());
		map.put("sacAddTime",this.getSacAddTime());
		map.put("sacStatus",this.getSacStatus());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static SrvApiClient fromMap(Map map){
		SrvApiClient srvApiClient = new SrvApiClient();
		srvApiClient.sacId = Utils.parseLong(map.get("sacId"));
		srvApiClient.sacClient = Utils.parseString(map.get("sacClient"));
		srvApiClient.sacSecret = Utils.parseString(map.get("sacSecret"));
		srvApiClient.sacType = Utils.parseShort(map.get("sacType"));
		srvApiClient.sacUrl = Utils.parseString(map.get("sacUrl"));
		srvApiClient.sacDesc = Utils.parseString(map.get("sacDesc"));
		srvApiClient.sacUpdateTime = Utils.parseDate(map.get("sacUpdateTime"));
		srvApiClient.sacAddTime = Utils.parseDate(map.get("sacAddTime"));
		srvApiClient.sacStatus = Utils.parseShort(map.get("sacStatus"));
		return srvApiClient;
	}
	
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(SrvApiClient old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/2008825642250778047.png";
	}
	public static String getIconfont(){
		return "icon-wjdq";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,SrvApiClient.M params){
		if(params==null)params=new SrvApiClient.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/api/apiclient.edit.html?";
		if(params.get("sacId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("sacId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/api/apiclient.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.sacId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(SrvApiClient.ACT act,SrvApiClient.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",SrvApiClient.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(SrvApiClient.ACT act,SrvApiClient.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",SrvApiClient.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ISrvApiClientDao getSrvApiClientDao(){
		return Utils.getBean("srvApiClientDao");
	};
	
}